package com.kunyi.web.service.file.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.kunyi.web.service.file.entity.domain.ExportTemplate;
import org.springframework.stereotype.Repository;

/**
 * @ClassName IDemoMapper
 * @Description export_template表交互
 * @Author pengjunjun
 * @Date 2024/03/04
 * @Version 1.0
 **/
@Repository
public interface IExportTemplateMapper extends BaseMapper<ExportTemplate> {
    default boolean isExistByCode(String code){
        ExportTemplate exportTemplate = selectOne(Wrappers.lambdaQuery(ExportTemplate.class)
                .select(ExportTemplate::getId)
                .eq(ExportTemplate::getCode, code)
                .last(" limit 1 ")
        );
        return exportTemplate != null && exportTemplate.getId() != null && exportTemplate.getId() > 0;
    }

    default ExportTemplate getByCode(String code){
        ExportTemplate exportTemplate = selectOne(Wrappers.lambdaQuery(ExportTemplate.class)
                .eq(ExportTemplate::getCode, code)
                .last(" limit 1 ")
        );
        return exportTemplate;
    }
}
